package com.example.listview;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.widget.Button;
import android.content.Intent;
import android.view.View;
import android.widget.Toast;

import com.example.listview.ListView.ListActivity;


public class MainActivity extends AppCompatActivity {


    private Button mBtnListView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mBtnListView = (Button) findViewById(R.id.btn_listview);
        setListers();
    }

    private void setListers() {
        OnClick onClick = new OnClick();
        mBtnListView.setOnClickListener(onClick);
    }


    //这个类给setListers()使用
    private class OnClick implements View.OnClickListener {
        @Override
        public void onClick(View view) {
            Intent intent = null;
            switch (view.getId()) {
                case R.id.btn_listview:
                    //跳转到ListActivity界面上
                    intent = new Intent(MainActivity.this, ListActivity.class);
                    startActivity(intent);
                    break;
                default:
                    break;
            }
        }
    }
}
